//
//  test1ViewController.m
//  CQFramework
//
//  Created by runo on 16/5/30.
//  Copyright © 2016年 caoqin. All rights reserved.
//

#import "test1ViewController.h"

typedef void(^HAHA)(UIViewController *vc);

@interface test1ViewController ()

@property(nonatomic,assign) NSInteger count;
@property(nonatomic,weak) HAHA haha;

@end

@implementation test1ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSInteger count = self.navigationController.viewControllers.count;
    self.title = [NSString stringWithFormat:@"%ld ",count];
    self.view.backgroundColor = kRedColor;
    self.count = count;
    UIButton *btn = [CQButtonFactory cqCommButton];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    __block test1ViewController *weakself = self;
    self.haha = ^(UIViewController *vc){
        
       // [self test];
        [weakself test];
    };
    
    self.haha(weakself);
    
    
    NSLog(@"开始");
    
    dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, 10);
    dispatch_after(time, dispatch_get_main_queue(), ^{

        NSLog(@"结束");
    });
    // Do any additional setup after loading the view.

}


-(void)test{
    NSLog(@"test");
}

-(void)btnClick{
    
    [CQCommon cqShowYesOrNoAlert:self Title:@"是否近下一页" Message:@"hehe" Yes:^{
        UIView *view = self.view;
        [self.navigationController pushViewController:[test1ViewController new] animated:YES];
        
        
    } No:^{
        
        
        
    }];
    
}

//多参数函数实现
-(void) CQNSLog:(NSString *)fromat, ...
{
    // 提取整个参数列表 并输出
    va_list argp;
    va_start(argp, fromat);

    id printfString = va_arg(argp, id);
    while(printfString)
    {
        NSLog(@"%@",printfString);
        printfString = va_arg(argp, id);
    }
    va_end(argp);
}

-(void)dealloc{
    
    NSLog(@"%ld death  %ld",self.navigationController.viewControllers.count,self.count);
    
}

@end
